package com.gl.rent;

import com.haixiaoke.saas.repository.core.AjaxResult;
import com.haixiaoke.saas.repository.service.IAreaService;
import com.haixiaoke.saas.repository.util.Tree.Node;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 区域选择
 */
@RestController
@RequestMapping("/area/picker")
public class AreaPickerController {

    @Autowired
    private IAreaService areaService;

    /**
     * 省 - 市
     * 比如: 广东省 - 广州市
     */
    @GetMapping("/level2")
    public AjaxResult getLevel2() {
        List<Node> nodes = areaService.getLevel2();
        return AjaxResult.success(nodes);
    }

    /**
     * 省 - 市 - 区
     * 比如: 广东省 - 广州市 - 天河区
     */
    @GetMapping("/level3")
    public AjaxResult getLevel3() {
        List<Node> nodes = areaService.getLevel3();
        return AjaxResult.success(nodes);
    }

}
